package org.tangjl.multidatasource.dynamic;

import org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSource;

public class DynamicDataSource extends AbstractRoutingDataSource {

    /**
     * 该类继承org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSource
     * Spring会在获取数据源时自动调用
     * 详情请查看Spring源码
     * {@link AbstractRoutingDataSource#determineTargetDataSource()}
     */
    @Override
    protected Object determineCurrentLookupKey() {
        return DynamicDataSourceContextHolder.get();
    }
}